class CreateRights < ActiveRecord::Migration
  def self.up
    create_table :rights do |t|
      #grant access on
      t.integer :protectable_id

      #to
      t.integer :role_id
      t.integer :group_id
      t.integer :user_id
      
      #with coindition
      t.boolean :delegatable
      t.boolean :to_upper_groups
      t.boolean :to_sub_groups
      t.boolean :to_group_managers_only
      t.boolean :to_other_roles
      
      #for quick match: extend role_ids, group_ids to user_ids
      t.boolean :is_cache 
      t.integer :extension_of_right_id #from whitch right it is generated

      t.timestamps
    end
  end

  def self.down
    drop_table :rights
  end
end
